package com.test.controller;


import com.test.domain.Result;
import com.test.domain.Utils;
import com.test.service.OpenOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@CrossOrigin
@RestController
@RequestMapping("/openOrder")
public class OpenOrderController {

    private final OpenOrderService openOrderService;

    @Autowired
    public OpenOrderController(OpenOrderService openOrderService) {
        this.openOrderService = openOrderService;
    }

    @GetMapping("/getOrderList")
    public Result getOrderList(@RequestParam("customerPhoneNumber") String customerPhoneNumber){
        return Utils.success(openOrderService.getOpenOrderListC(customerPhoneNumber));
    }

    @GetMapping("/getOrderListM")
    public Result getOrderListM(@RequestParam("merchantPhoneNumber") String merchantPhoneNumber){
        return Utils.success(openOrderService.getOpenOrderListM(merchantPhoneNumber));
    }

    @GetMapping("/update")
    public Result updateSituation(@RequestParam("merchantPhoneNumber")String merchantPhoneNumber,
                                  @RequestParam("orderNumber")String orderNumber){

        openOrderService.updateSituation(merchantPhoneNumber,orderNumber);
        return Utils.success("ok");
    }


}
